﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace Highkick.HOperation
{
    public class ReceiveController
    {
        public event Action OnReceive;

        Timer tmr;
        volatile int gctor = 0;
        public ReceiveController()
        {
            tmr = null;
        }

        public void Begin()
        {
            gctor = 0;
            tmr = new Timer((o) =>
                {
                    gctor++;
                    if (gctor >= Core.Config.ReceiveInterval)
                    {
                        gctor = 0;
                        try
                        {
                            OnReceive.Invoke();
                        }
                        catch { }
                    }
                }
            , null, 1000, 20000);
        }
    }
}
